package Demo1

import scala.io.Source


/**
  * Created by Administrator on 2017/2/9 0009.
  * 主辅构造器
  */
class Student(var name:String, val age:Int) {

  var gender = "male"
  println("主构造器被执行")

  Source.fromFile("F://dada.txt").mkString
  println("读取文件被执行")

  def testfunc: Unit = {
    println("主构造器里的方法")
  }

  //辅助构造器是对主构造器的补充

  def this(name:String,age:Int,gender:String){
    this(name,age)
    println("辅助构造器被执行")
    this.gender=gender
  }
}
